//
//  LGConsultationSummaryCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/3/23.
//  发送医嘱

#import "LGConsultationAdviceCell2.h"

@interface LGConsultationAdviceCell2()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)CAGradientLayer *gradientLayer;
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
//@property (nonatomic , strong)UIView *lineView;
///**   */
//@property (nonatomic , strong)UILabel *contentLabel;
/**   */
@property (nonatomic , strong)UIButton *checkBtn;
/**   */
@property (nonatomic , strong)LGCustomCellData *cellData;
/**   */
@property (nonatomic , copy)NSString *recordid;

@end

@implementation LGConsultationAdviceCell2

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
//        self.contentView.backgroundColor = [UIColor redColor];
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    [super setDataDic:dataDic];
    self.bubbleView.image = self.receiverBubble;
    NSDictionary *contentDic = [ObjectTool jsonToObject:dataDic[@"content"][@"ext"]];
    self.recordid = LGNSString(contentDic[@"bus_id"]);
    NSDictionary *tempDic = contentDic[@"msgcontent_doctor"];
    NSString *title = LGNSString(tempDic[@"title"]);
    NSString *doctorName = [NSString stringWithFormat:@"%@ %@",tempDic[@"doctor_name"],tempDic[@"title"]];
    self.titleLabel.attributedText = [doctorName attributeString:@{NSFontAttributeName:LGFont(14)} range:NSMakeRange(doctorName.length-title.length, title.length)];
    [self.bubbleView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(Screen_W-viewPix(100)));
    }];
}


//查看医嘱详情
-(void)checkAdviceDetailAction{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"CheckDoctorAdviceDetail2" object:nil userInfo:@{@"recordid":self.recordid}];
}


#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    [self.bubbleView addSubview:self.baseView];
    [self.baseView addSubview:self.titleLabel];
    [self.baseView addSubview:self.checkBtn];
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.equalTo(self.bubbleView);
        make.width.equalTo(@(Screen_W-viewPix(100)));
    }];
    [self.checkBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.baseView).offset(-viewPix(12));
        make.left.equalTo(self.baseView).offset(viewPix(16));
        make.right.equalTo(self.baseView).offset(-viewPix(16));
        make.height.equalTo(@(viewPix(30)));
    }];
}
-(UIView *)baseView{
    if(!_baseView){
        _baseView = [[UIView alloc] init];
        _baseView.backgroundColor = [UIColor whiteColor];
        _baseView.cornerRidus = 15;
    }
    return _baseView;
}

-(CAGradientLayer *)gradientLayer{
    if(!_gradientLayer){
        _gradientLayer = [[CAGradientLayer alloc]init];
        _gradientLayer.startPoint = CGPointMake(0.5, 0);
        _gradientLayer.endPoint = CGPointMake(0.5, 0.6);
        _gradientLayer.colors = @[(__bridge id)[UIColor colorWithString:@"#E4F2FF"].CGColor, (__bridge id)[UIColor colorWithString:@"#FFFFFF"].CGColor];
        _gradientLayer.locations = @[@(0), @(1.0f)];
    }
    return _gradientLayer;
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(14, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
        _titleLabel.frame = CGRectMake(viewPix(12), viewPix(12), Screen_W-viewPix(124), viewPix(20));
    }
    return _titleLabel;
}

//-(UIView *)lineView{
//    if(!_lineView){
//        _lineView = [[UIView alloc] initWithFrame:CGRectMake(viewPix(12), viewPix(40), Screen_W-viewPix(124), 0.5)];
//        _lineView.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
//    }
//    return _lineView;
//}
//
//-(UILabel *)contentLabel{
//    if(!_contentLabel){
//        _contentLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:0];
//    }
//    return _contentLabel;
//}

-(UIButton *)checkBtn{
    if(!_checkBtn){
        _checkBtn = [UIButton buttonWithTitle:@"立即查看" titleFont:LGFontWeight(14, UIFontWeightMedium) textColor:@"#3291FF" imageName:@""];
        _checkBtn.layer.borderColor = [UIColor colorWithString:@"#CCE4FF"].CGColor;
        _checkBtn.layer.borderWidth = 1;
        _checkBtn.cornerRidus = viewPix(15);
        [_checkBtn addTarget:self action:@selector(checkAdviceDetailAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _checkBtn;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
